(1) Field of the Invention
The present invention relates to a program control device, namely an Operating System (OS), which switches between threads to be executed per timeslot.
(2) Description of the Related Art
Main functions of an OS are hardware management, thread management, data management, and input/output management. Among these managements, the thread management is for managing an order of executing threads, and is an important function of allowing a CPU, memories, input/output devices and the like to operate efficiently.
Here, the “thread” is a unit to be controlled (control unit), for managing a flow of startup, execution, and exit, and the like of a program.
A program operating under the management of an OS is treated as a thread, and every processing of the OS regarding execution of the program is performed in units of threads.
One of algorithms for deciding an order of executing threads is round-robin scheduling. In the round-robin scheduling, an execution time is allocated to a thread which is a control unit, and during the allocated execution time the thread has an execution permission of executing a program, but after the allocated execution time the execution permission is transferred to a different thread. Thereby, such an execution permission is allocated to each thread, equally and with a predetermined time period.
In real-time computing in which media processing is performed by a processor, it is necessary to perform various processing such as coding, decoding, and multiplexing at the same time. Therefore, in order to allocate the execution permission equally, each function for realizing the media processing is divided into threads, and the execution permission is allocated to each function. Thereby, the round-robin scheduling can be applied in the real-time computing.
However, the round-robin scheduling has a problem in responsiveness in the real-time computing, because once a thread loses an execution permission, a next execution permission is given after one cycle. Although the responsiveness is improved by reducing a duration of the cycle, the shorter the cycle is, the higher an overhead of switching execution permissions becomes. In order to solve the problem of the overhead of switching execution permissions, there is disclosed in Japanese Patent No. 3813930 a processor which saves and restores contexts by using hardware.
Moreover, when the above prior art is implemented by a multiprocessor, there is a problem of deciding to which processor a thread is to be allocated.
In symmetric multiprocessors, threads are allocated to processors dynamically at scheduling, so that system loads are distributed to a plurality of processors. Therefore, it is difficult to allocate an execution time per thread.
Therefore, it is necessary to fix processors when the processors are allocated per thread. It is known, from “Real-Time Operating System for Function Distributed Multiprocessors”, Journal of Information Processing Society of Japan, Vol. 47, No. 1, 2006, to provide a real-time OS which decides processors to be allocated per thread and performs priority scheduling per processor.
However, in the above prior art, with the increase of the number of threads, the number of switching within one cycle that is a total period of all timeslots is increased, and a region in which contexts are managed is also increased. Therefore, it is difficult to ensure demanded performance for each thread.
In addition, in the multiprocessors, when a certain processor is directly allocated to each thread, description in the thread depends on the processor. Therefore, if a configuration of the multiprocessor is changed, the description in the thread needs to be changed. As a result, there is a problem of poor flexibility in thread designing.
In order to solve the above problems, the first object of the present invention is to provide a program control device which satisfies demanded performance of a plurality of threads. Furthermore, the second object of the present invention is to provide a program control device which ensures flexibility of program designing.